package com.caiheng.api.service.mer.impl;

import com.caiheng.api.dao.mer.MerCategoryMapper;
import com.caiheng.api.dao.mer.MerMapper;
import com.caiheng.api.entity.mer.Mer;
import com.caiheng.api.entity.mer.MerCategory;
import com.caiheng.api.service.base.impl.BaseServiceImpl;
import com.caiheng.api.service.mer.MerCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商家的所属分类Service业务层处理
 *
 * @author ruoyi
 * @date 2022-06-20
 */
@Service
public class MerCategoryServiceImpl extends BaseServiceImpl<MerCategoryMapper, MerCategory> implements MerCategoryService {

    @Resource
    private MerCategoryMapper categoryMapper;
    @Resource
    private MerMapper merMapper;

    @Override
    public void resetCategory() {
        List<Mer> mers = merMapper.selectAllList();
        for (Mer mer : mers){
            MerCategory merCategory = new MerCategory();
            merCategory.setMerId(mer.getId());
            merCategory.setCateId(2);
            merCategory.setCateChildId(mer.getCateChildId());
            categoryMapper.insert(merCategory);
        }
    }
}
